Golang GUI编程:walk.WebView实现web app | 您所在的位置:网站首页 › go gui编程vue › Golang GUI编程:walk.WebView实现web app |
本程序采用github.com/lxn/walk的walk.WebView实现一个GUI程序,启动一个http server,GUI访问本地http server。 支持写日志、响应键盘事件等。 完整代码: main.go //先安装mingw64 package main import ( "os" "strings" "time" "github.com/go-vgo/robotgo" "github.com/lxn/walk" . "github.com/lxn/walk/declarative" hook "github.com/robotn/gohook" ) //写日志 func WriteLog(str_content string) { fd, _ := os.OpenFile("./log.txt", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644) fd_time := time.Now().Format("2006-01-02 15:04:05") fd_content := strings.Join([]string{fd_time, ": ", str_content, "\n"}, "") buf := []byte(fd_content) fd.Write(buf) fd.Close() } //响应键盘事件 func KeyEvent() { for 1 == 1 { robotgo.EventHook(hook.KeyDown, []string{"esc"}, func(e hook.Event) { if isFullScreen { NormalScreen() }else{ FullScreen() } robotgo.EventEnd() }) s := robotgo.EventStart() |
CopyRight 2018-2019 实验室设备网 版权所有 |